package cl.yapal.inventory.dao;


import cl.yapal.inventory.vo.Product;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


public class DatabaseAccessImpl extends HibernateDaoSupport implements DatabaseAccess{

    private void storeData(Object data) throws DaoException{

        try{
            Session session = SessionFactoryUtils.getSession(getSessionFactory(),false);
            session.save(data);
        }catch(RuntimeException e){
            throw new DaoException(e);
        }
    }


    public void addProduct(Product product) throws DaoException {
        storeData(product);
    }



    public Product searchProduct(String productCode) throws DaoException {
        return null;
    }

    public void decreaseProduct(String productCode, int quantity) throws DaoException {
        

    }

    public void increaseProduct(String productCode, int quantity) throws DaoException {

    }


}
